using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wlmy.Ids4.Model;
using Wlmy.Ids4.Model.Dto.CommonOutput;
using Wlmy.Ids4.Model.Dto.User;
using Wlmy.Ids4.Repository;

namespace Wlmy.Ids4.Services
{
    public class UserServices : BaseServices<User>, IUserServices
    {
        public UserServices(IUserRepository repository)
            : base(repository)
        {

        }

        public async Task<PageRequestOutput<GetUserListOutput>> GetUserList(GetUserListInput input)
        {
            var query = GetALL();
            var count = await query.CountAsync();
            var list = await query.Include(x=>x.Claims).Skip((input.PageIndex - 1) * input.PageSize).Take(input.PageSize).ToListAsync();
            var dtoList = mapper.Map <List<GetUserListOutput>>(list);
            return new PageRequestOutput<GetUserListOutput>(dtoList, count);
        }
    }
}
